Skip to content

feat: differentiate simple/advanced API for fabrica payloads - #131

Merged
synackd merged 2 commits into
mainfrom
feat/advanced-payload-api
Jul 30, 2026
Merged

feat: differentiate simple/advanced API for fabrica payloads#131
synackd merged 2 commits into
mainfrom
feat/advanced-payload-api

Conversation

@synackd

@synackd synackd commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Implement API changes from OpenCHAMI/fabrica#64.

Add --envelope flag to fabrica resource commands to allow the user to specify additional metadata that envelops the spec, which contains the actual data. By default (without --envelope), the payload is just the spec and additional metadata is ignored.

Fixes #115

Checklist

  • My code follows the style guidelines of this project
  • I have added/updated comments where needed
  • I have added tests that prove my fix is effective or my feature works
  • I have run make test (or equivalent) locally and all tests pass
  • I have updated the relevant documentation (CLI examples, man pages, README, other docs, etc.)
  • DCO Sign-off: All commits are signed off (git commit -s) with my real name and email
  • REUSE Compliance:
    • Each new/modified source file has SPDX copyright and license headers
    • Any non-commentable files include a <filename>.license sidecar
    • All referenced licenses are present in the LICENSES/ directory

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Dependency update

For more info, see Contributing Guidelines.

Implement API changes from OpenCHAMI/fabrica#64.

Add --envelope flag to fabrica resource commands to allow the user to
specify additional metadata that envelops the spec, which contains the
actual data. By default (without --envelope), the payload is just the
spec and additional metadata is ignored.

Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
@synackd synackd added the needs testing Needs more testing before approval label Jul 29, 2026
Comment thread cmd/boot/bmc/add.go
Comment thread cmd/boot/bmc/add.go
@synackd

synackd commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

I need to refactor this a bit due to some potential confusion arising from the current simple-vs-advanced API data structure (see https://github.com/OpenCHAMI/ochami/pull/131/changes/BASE..ee8d4d1a4457f7c7ee1fe2d1126bcc2fe5bfd303#r3676368580).

Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
@synackd

synackd commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@davidallendj I've refactored the code so that the simple API only accepts the spec (without having to specify spec:) and accepts a top-level name: field. Docs, examples, and tests have also been updated.

@davidallendj

Copy link
Copy Markdown
Contributor

Alright, let me have another look at it.

@davidallendj

Copy link
Copy Markdown
Contributor

This works how I would expect it to and fails with a validation error when trying to use the simple API to add and works when the -e flag is included.

[rocky@openchami-testing ochami]$ ./ochami metadata defaults add -d@/etc/openchami/data/cloud-init/ci-defaults.yaml
2026-07-30T17:58:54Z ERR add.go:151 > failed to add cluster defaults error="failed to add cluster defaults \"\" ({Description: BaseURL: CloudProvider: Region: AvailabilityZone: ClusterName: ShortName: NidLength:0 PublicKeys:[]}): API error (400): validation failed: base_url is required; cluster_name is required"
2026-07-30T17:58:54Z ERR cli.go:652 > see 'ochami metadata defaults add --help' for long command help
2026-07-30T17:58:54Z WRN add.go:166 > Cluster defaults addition completed with errors
[rocky@openchami-testing ochami]$ ./ochami metadata defaults add -e -d@/etc/openchami/data/cloud-init/ci-defaults.yaml

Here is the file contents that are used in the commands above.

[rocky@openchami-testing ochami]$ cat /etc/openchami/data/cloud-init/ci-defaults.yaml
{
  "spec": {
    "base_url": "http://172.16.0.254:8081/cloud-init",
    "cluster_name": "demo",
    "nid-length": 2,
    "public-keys": [
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPhN/tcp4FPcZtym/yvDpeGdbCr0mMH0gA7ULBE1m7sk rocky@openchami-testing.novalocal"
      ],
    "short-name": "de"
  }
}

I tried the simple version again with removing the spec and it works like expected as well.

[rocky@openchami-testing ochami]$ ./ochami metadata defaults add -d@/etc/openchami/data/cloud-init/ci-defaults.simple.yaml
[rocky@openchami-testing ochami]$ cat /etc/openchami/data/cloud-init/ci-defaults.simple.yaml 
{
    "base_url": "http://172.16.0.254:8081/cloud-init",
    "cluster_name": "demo",
    "nid-length": 2,
    "public-keys": [
      "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPhN/tcp4FPcZtym/yvDpeGdbCr0mMH0gA7ULBE1m7sk rocky@openchami-testing.novalocal"
      ],
    "short-name": "de"
}

I tried adding the simple data format using the advanced API with -e and got the validation error as expected.

[rocky@openchami-testing ochami]$ ./ochami metadata defaults add -e -d@/etc/openchami/data/cloud-init/ci-defaults.simple.yaml
2026-07-30T18:08:21Z ERR add.go:151 > failed to add cluster defaults error="failed to add cluster defaults {Metadata:{Name: UID: Labels:map[] Annotations:map[] CreatedAt:0001-01-01 00:00:00 +0000 UTC UpdatedAt:0001-01-01 00:00:00 +0000 UTC} Spec:{Description: BaseURL: CloudProvider: Region: AvailabilityZone: ClusterName: ShortName: NidLength:0 PublicKeys:[]} Labels:map[] Annotations:map[]}: API error (400): validation failed: base_url is required; cluster_name is required"
2026-07-30T18:08:21Z ERR cli.go:652 > see 'ochami metadata defaults add --help' for long command help
2026-07-30T18:08:21Z WRN add.go:166 > Cluster defaults addition completed with errors

@davidallendj davidallendj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes looks good, works like expected, and all tests passed.

@synackd synackd removed the needs testing Needs more testing before approval label Jul 30, 2026
@synackd
synackd merged commit f810c26 into main Jul 30, 2026
14 checks passed
@synackd
synackd deleted the feat/advanced-payload-api branch July 30, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DEV] Update service deps and CLI docs for new data format

2 participants